﻿#region Using

using System.Collections.Generic;
using System.ComponentModel;

#endregion Using

namespace T4_Eind_programma
{
    public class Order : INotifyPropertyChanged
    {
        #region Variable Declaration

        private bool klaar;
        private BindingList<Mengbatch> mengbatchList = new BindingList<Mengbatch>();
        private string naam;
        private int nummer;
        private string status;

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion Variable Declaration

        #region Properties

        public bool Klaar
        {
            get { return klaar; }
            set
            {
                SetField(ref klaar, value, "Klaar");
            }
        }

        public BindingList<Mengbatch> MengbatchList
        {
            get { return mengbatchList; }
            set
            {
                SetField(ref mengbatchList, value, "MengbatchList");
            }
        }

        public string Naam
        {
            get { return naam; }
            set { naam = value; }
        }

        public int Nummer
        {
            get { return nummer; }
            set { nummer = value; }
        }

        public string Status
        {
            get { return status; }
            set { status = value; }
        }

        #endregion Properties

        #region Constructor

        public Order(int nummer, string naam, bool klaar)
        {
            this.nummer = nummer;
            this.naam = naam;
            this.klaar = klaar;
        }

        #endregion Constructor

        #region NotifyChanged

        protected virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }

        protected bool SetField<T>(ref T field, T value, string propertyName)
        {
            if (EqualityComparer<T>.Default.Equals(field, value)) return false;
            field = value;
            OnPropertyChanged(propertyName);
            return true;
        }

        #endregion NotifyChanged
    }
}